home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Befund4a.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-22
|
3KB
|
98 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Befund4a.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
const String DateiName = "Diagnose.txt";
const String SammelName = "PsychoX.txt";
TForm1 *Form1;
TStringList *Diagnose;
TStringList *Psycho;
int Nr;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
randomize ();
Diagnose = new TStringList;
Psycho = new TStringList;
Diagnose->Add ("Keine Sprechstunde");
ScrollBar1->Min = 0;
ScrollBar1->Max = Diagnose->Count - 1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Panel1->Caption = "";
Edit1->Text = "";
Edit1->SetFocus ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Psycho->Add (Edit1->Text);
Nr = random (Diagnose->Count);
Panel1->Caption = Diagnose->Strings[Nr];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ScrollBar1Change(TObject *Sender)
{
Panel1->Caption = Diagnose->Strings[ScrollBar1->Position];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Oeffnen1Click(TObject *Sender)
{
try
{
if (OpenDialog1->Execute ())
Diagnose->LoadFromFile (OpenDialog1->FileName);
ScrollBar1->Max = Diagnose->Count - 1;
}
catch (...)
{
Application->MessageBox
("Fehler beim ╓ffnen der Datei!", "Achtung!", 0+48);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Speichern1Click(TObject *Sender)
{
try
{
if (SaveDialog1->Execute ())
Psycho->SaveToFile (SaveDialog1->FileName);
}
catch (...)
{
Application->MessageBox
("Fehler beim Speichern der Datei!", "Achtung!", 0+48);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Drucken1Click(TObject *Sender)
{
try
{
if (PrintDialog1->Execute ())
{
RichEdit1->Text = Diagnose->Text;
RichEdit1->Print ("Diagnose");
}
}
catch (...)
{
Application->MessageBox
("Fehler beim Drucken der Datei!", "Achtung!", 0+48);
}
}
//---------------------------------------------------------------------------